package orz.itrip;

import java.util.Calendar;
import java.util.Date;

public class DateUtils {
    public static Integer getWeek(Date date){
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        Integer week_index = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if(week_index<0){
            week_index = 7;
        }
        return week_index;
    }
    public static Date changeDate(Date date,Integer hour,Integer minute,Integer second){
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.set(Calendar.HOUR_OF_DAY, hour);
        calendar.set(Calendar.MINUTE, minute);
        calendar.set(Calendar.SECOND, second);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar.getTime();
    }
}
